package org.micode.demo.biz.service.impl;

import org.micode.common.helper.I18nMsgHelper;
import org.micode.demo.biz.service.BizSysConfigService;
import org.micode.demo.biz.service.BizConfigService;
import lombok.extern.slf4j.Slf4j;
import org.micode.demo.biz.service.BizSysDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class BizConfigServiceImpl implements BizConfigService {

    @Autowired
    private BizSysConfigService bizSysConfigService;

    @Autowired
    private BizSysDictionaryService bizSysDictionaryService;

    @Override
    public Boolean reloadConfig(String clientIp) {
        if ("127.0.0.1".equals(clientIp)) {
            try {
                bizSysConfigService.reloadConfig();
                return true;
            } catch (Exception e) {
                log.error(I18nMsgHelper.get("fail.BizConfigServiceImpl-reloadConfig.call"), e);
            }
        }
        return false;
    }

    @Override
    public void loadSysConfig() {
        bizSysConfigService.loadSysConfigCache();
    }

    @Override
    public void loadSysDictionary() {
        bizSysDictionaryService.loadSysDictionaryCache();
    }

}
